Questions
22 of 30
1What is the purpose of the transform property in CSS?
2What are the different types of CSS transformations?
3What does transform: translate() do?
4What is the difference between translateX() and translateY()?
5How does rotate() work in CSS?
6What is the unit used in rotation?
7What is the difference between scale() and scaleX(), scaleY()?
8What happens when you use negative values in scale()?
9What does the skew() function do?
10Can you combine multiple transform functions together? How? What is the use of the transform-origin property?
11What is the default transform-origin value?
12How does changing transform-origin affect rotation or scaling?
13What is the difference between translate() and using position or margin for movement?
14What is the difference between 2D and 3D transformations?
15What is the difference between 2D and 3D transformations?
16How do you apply a 3D rotation using CSS?
17How do you apply a 3D rotation using CSS?
18What are perspective and perspective-origin in 3D transforms? What is the purpose of transform-style: preserve-3d?
19What is the use of matrix() in CSS transforms?
20What’s the difference between matrix() and matrix3d()?
21How can you center an element using transform and translate()?
22What is the transition property in CSS used for?
23What are the four main components of a transition?
24What does transition-duration specify?
25What are the common timing function values (e.g., ease, linear, ease-in)?
26What is the shorthand syntax for transition?
27Can multiple CSS properties be transitioned simultaneously? How does transition differ from animation in CSS?
28Can you apply a transition to an element’s pseudo-class (like :hover)?
29Can transitions be triggered by JavaScript?
30What happens if transition-duration is set to 0s?
22 / 30

What is the transition property in CSS used for?

Using transform and translate() for Smooth Transitions and Centering in CSS

The transition property in CSS controls how property changes occur over time, allowing smooth animations when a property value changes. It is often used with transform properties like translate() to create fluid movement and scaling effects.

To perfectly center an element, you can use position and transform: translate(-50%, -50%). This keeps the element centered regardless of its size, even when animated with a transition.

Example: Centering with translate() and Adding a Transition

In this example, the transition property smoothly animates the scaling effect when the element is hovered, maintaining its centered position.

Basic Syntax
Example Components
  1. 1

    property — which CSS property to animate (e.g., transform, background-color).

  2. 2

    duration — how long the transition takes (e.g., 0.4s).

  3. 3

    timing-function — how the speed changes (e.g., ease, linear).

  4. 4

    delay — when the animation should start.

Key Takeaways
  1. 1

    Use transition to animate CSS property changes smoothly.

  2. 2

    Combine transform with translate() for precise centering and movement.

  3. 3

    Transitions can apply to scale, rotation, opacity, and more for elegant UI effects.